/**
 * The CfgMngr configuration interface, allowing the retrieval and management
 * of subsystem configurations.
 */
package za.org.jcicada.cfgmngr;

import java.net.URI;

import za.org.jcicada.genss.ServiceURN;
import za.org.jcicada.genss.SystemURN;

/**
 * The CfgMngr configuration interface, allowing the retrieval and management of
 * subsystem configurations, as well as registering, deregistering and locating
 * services provided by subsystems
 */
public interface IConfigurationServer {
	
	/**
	 * Get a handle to the system subject that is used to distribute system
	 * registration events to attached observers.
	 * @return the system subject
	 */
	ISystemSubject getSystemSubject();
	
	/**
	 * Get a handle to the physical server that is used to associate systems
	 * with physical nodes.
	 * @return the physical server
	 */
	IPhysicalServer getPhysicalServer();
	
    /**
     * Retrieves the configuration for the subsystem specified
     * 
     * @param systemURN the subsystem URI for which the configuration is to be
     *            retrieved
     * @param client the client to which the reply message must be sent
     * @param systemURN the subsystem for which the configuration is retrieved
     * @return no return object - information will be returned via the
     *         appropriate reply message
     */
    void requestGetConfiguration(IConfigurationClient client, SystemURN systemURN);

    /**
     * updateConfiguration - Not yet implemented for Fringe Finder
     */
    // void updateConfiguration(URI subsystemURI, URI configurationURI, Object
    // configuration);
    /*
     * The CfgMngr services interface allowing clients to register, locate and
     * deregister services.
     */

    /**
     * Locates the provider of the service requested.
     * 
     * @param client the client to which the reply message must be sent
     * @param serviceURN the service for which a provider is required
     * @param protocol the desired protocol for the location
     * @return no return object - information will be returned via the
     *         appropriate reply message found
     */
    void requestLocateService(IConfigurationClient client, ServiceURN serviceURN, String protocol);

    /**
     * Registers services provided by a subsystem.
     * 
     * @param client the client to which the reply message must be sent
     * @param subsystemURI location of the subsystem offering the service
     * @param serviceURI the service the subsystem provides
     */
    void requestRegisterService(IConfigurationClient client, URI locationURI, ServiceURN serviceURN);

    /**
     * Deregisters services previously provided by a subsystem.
     * 
     * @param client the client to which the reply message must be sent
     * @param locationURI location of the subsystem no longer providing the
     *            services
     * @param serviceURI the service the subsystem is no longer providing
     */
    void requestDeregisterService(IConfigurationClient client, URI locationURI, ServiceURN serviceURN);

    /**
     * Registers a system.
     * 
     * @param client the client to which the reply message must be sent
     * @param systemURN subsystem URI
     */
    void requestRegisterSystem(IConfigurationClient client, SystemURN systemURN);

    /**
     * Deregisters a system.
     * 
     * @param client the client to which the reply message must be sent
     * @param systemURN subsystem URI
     */
    void requestDeregisterSystem(IConfigurationClient client, SystemURN systemURN);

    /**
     * Get the set of all registered systems
     * 
     * @param client the client to which the reply message must be sent
     * @param type the type of system set to request
     */
    void requestSystemSet(IConfigurationClient client, SystemSetType type);

    /**
     * Get the set of all sensors for a system
     * 
     * @param client the client to which the reply message must be sent
     * @param systemURN the system for which the sensors set is required
     */
    void requestSensorSet(IConfigurationClient client, SystemURN systemURN);
    
    /**
     * get the set of all services for a system
     * 
     * @param client the client to which the reply message must be sent
     * @param systemURN the system for which the services set is required
     */
    void requestServiceSet(IConfigurationClient client, SystemURN systemURN);

    /**
     * Inform the subject that the observer has disconnected.
     * 
     * @param client the client that is disconnecting
     */
    void informDisconnect(IConfigurationClient client);

}
